# Maintainer: George Rawlinson <george@rawlinson.net.nz>
# Contributor: Max Mehl <aur at mehl dot mx>
# SPDX-FileCopyrightText: 2019 Max Mehl
# SPDX-License-Identifier: CC0-1.0

pkgname=reuse
pkgver=1.1.2
pkgrel=2
pkgdesc='Helper tool for providing and confirming copyright and licensing information'
arch=('any')
url='https://reuse.software/'
license=('GPL3' 'Apache' 'custom:CC0-1.0')
depends=(
  'python'
  'python-debian'
  'python-license-expression'
  'python-boolean.py'
  'python-jinja'
  'python-binaryornot'
  'python-setuptools' 
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-wheel'
  'python-poetry-core'
)
checkdepends=('python-pytest')
optdepends=(
  'git: git repository support'
  'mercurial: mercurial repository support'
)
_commit='86f057b616d7f8c0a9d524c1c1a25e8ee3883101'
source=("$pkgname::git+https://github.com/fsfe/reuse-tool#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  python -m build --wheel --no-isolation
}

check() {
  cd "$pkgname"

  pytest -v
}

package() {
  cd "$pkgname"

  python -m installer --destdir="$pkgdir" dist/*.whl

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" ./*.{rst,md}

  # licenses
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSES/*

  sed -n '/## License/,$ p' README.md > "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
